﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Http;
using Entities;
using Sales.DataAccess.DO;

namespace Sales.WebAPI.Controllers
{
    public class FoodController : ApiController
    {
        private FoodDO FoodDO;

        public FoodController()
        {
            FoodDO = new FoodDO();
        }
        
        // GET api/values
        public IEnumerable<Food_Beverage> Get()
        {
            return FoodDO.GetAll();
        }

        // GET api/values/5
        public Food_Beverage Get(int id)
        {
            return FoodDO.GetSingle(cus => cus.FID == id);
        }

        // POST api/values
        public void Post(Food_Beverage food)
        {
            FoodDO.Add(food);
        }

        // PUT api/values/5
        public void Put(int id, Food_Beverage food)
        {
            food.FID = id;
            FoodDO.Update(food);
        }

        // DELETE api/values/5
        public void Delete(int id)
        {
            var food = FoodDO.GetSingle(cus => cus.FID == id);
            FoodDO.Remove(food);
        }

    }
}
